package android.FiltrosJava;

import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;

public class ShearTransform extends AbstractImageBasic{
	protected double sx, sy;
	protected boolean convertToRGB = false;
	
	public ShearTransform(double shearX, double shearY, boolean forceToRGB){
		setShear(shearX, shearY,forceToRGB);
	}
	
	public void setShear(double shearX, double shearY, boolean forceToRGB){
		sx = shearX;
		sy = shearY;
		convertToRGB = forceToRGB;
	}
	
	public BufferedImage applyFilter(BufferedImage src) {
		//BufferedImage dst = convertImageToARGB(src);
		BufferedImage dst = src;
		convertImageToARGB(dst);
		
		AffineTransform xform = new AffineTransform();		
		xform.shear(sx,sy);		
		AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);

		dst = op.filter(dst, null);
		if (convertToRGB){
			//return convertImageToRGB(dst);
			convertImageToRGB(dst);
			return dst;
		}
		else
			return dst;
    }	
}

